<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
        <input class = "one" type="text" >

        <button>提交</button>

        <div style="font-size:25px">请输入要猜的数字:</div>

        <script>
                let one = document.querySelector('input');
                let button = document.querySelector('button');
                let div = document.querySelector('div'); 

                let rand = Math.floor(Math.random()*100+1);
                console.log(rand);

                button.onclick = function() {
                    let sun = parseInt(one.value);

                    if(sun > rand) {
                        div.innerHTML = '猜大了';
                    }else if(sun < rand) {
                        div.innerHTML = '猜小了';
                    }else {
                        div.innerHTML = '猜对了';
                    }
                }

        </script>
</body>
</html>